/* File gfx_skitchin.h */
#ifndef GFX_SKITCHIN_H
#define GFX_SKITCHIN_H

#include <stdio.h>
#include "GameTimer.h"

// To-DO: replace void pointers with custom types

// Forward declarations
class CAbstractTexture;
struct SRect;
struct SRGB;
// Forward declarations

// Prototypes
SRGB ColorRGB( unsigned int r, unsigned int g, unsigned int b );
SRect RectXYWH( float X, float Y, unsigned int W, unsigned int H );
// Prototypes

struct SRect
{
      float x, y;
      unsigned int w, h;
};

struct SRGB
{
       int r;
       int g;
       int b;
};

// IMPLEMENT
class CAbstractDrawable
{
    protected:
		//
		SRect rctCoords;
		//unsigned int w, h;
		//int x, y;

		bool hflip;
		bool vflip;
		unsigned int u, v;
		unsigned int txw, txh; // Load from texture file
		SRGB maskcolor; // Load from texture file
		void * texturedata;
		char * texturefilename;
              
    public:
           
		CAbstractDrawable( )
		{
			vflip = false;hflip = false;
			rctCoords.w = rctCoords.h = u = v = 0;
			rctCoords.x = rctCoords.y = 0.0f;
			texturefilename = NULL; texturedata = NULL;
		}
		void * GetTexturePointer( ) { return texturedata; }
		char * GetTextureFileName( ) { return texturefilename; }

		bool GetHFlip( ) { return hflip; }
		bool GetVFlip( ) { return vflip; }
		unsigned int GetTXW( ) { return txw; }
		unsigned int GetTXH( ) { return txh; }
		unsigned int GetW( ) { return rctCoords.w; }
		unsigned int GetH( ) { return rctCoords.h; }
		unsigned int GetU( ) { return u; }
		unsigned int GetV( ) { return v; }
		float GetX( ) { return rctCoords.x; }
		float GetY( ) { return rctCoords.y; }

		void SetHFlip( bool _hflip ) { hflip = _hflip; }
		void SetVFlip( bool _vflip ) { vflip = _vflip; }
		void SetTXW( unsigned int _w ) { txw = _w; }
		void SetTXH ( unsigned int _h ) { txh = _h; }
		void SetW( unsigned int _w ) { rctCoords.w = _w; }
		void SetH( unsigned int _h ) { rctCoords.h = _h; }
		void SetU( unsigned int _u ) { u = _u; }
		void SetV( unsigned int _v ) { v = _v; }
		void SetX( float _x ) { rctCoords.x = _x; }
		void SetY( float _y ) { rctCoords.y = _y; }

		int SnapBounds( CAbstractDrawable* obj );
		bool IsOverlapping( CAbstractDrawable* obj );

		virtual int TextureFromFile( char * path, SRGB alphacolor ) = 0;
		virtual int TextureFromFile( char * path ) = 0;             
};

class CAbstractDrawingInterface
{
      protected:
				GameTimer tFPSTimer;
				GameTimer tFPSDelayTimer;

				bool bDoubleBuffer;

				int iFPSCounter;
				int iFPS2Display;
				int iFPSDelayTime;
				int iFPSLimit;

				SRect rctScreen;
				unsigned int Bpp;
				char * WindowTitle;

      public:
				CAbstractDrawingInterface();
                virtual int blit( CAbstractDrawable * drawable ) = 0;
                virtual void destroywindow( ) = 0;
                virtual void initwindow( unsigned int w, unsigned int h, unsigned int bpp, const char * title ) = 0; // w, h, title
                virtual void fillrect( SRGB color, SRect rectarea ) = 0; // rectarea = NULL, clear whole screen
                virtual void fillscreen( SRGB color ) = 0;
                virtual void swapbuffers( ) = 0;

				void CalcFPS( );
				unsigned int GetScreenH( ) { return rctScreen.h; }
				unsigned int GetScreenW( ) { return rctScreen.w; }
				unsigned int GetFPS( ) { return iFPS2Display; }
				unsigned int GetFPSLimit( ) { return iFPSLimit; }
				void SetFPSLimit( int FPS ) { iFPSLimit = FPS; }
				virtual int Tick( ) = 0;

				void ThrottleFPS( );
};

class CFont
{
	protected:
		//C

	public:
		CFont( );
		~CFont( );
};

#endif /* SKITCHIN_H */
